window.addEventListener('keydown', playVoice)
    // 封装键盘对应声音的方法
function playVoice(e) {
    const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`)
    const key = document.querySelector(`div[data-key="${e.keyCode}"]`)
    if (!audio) return
    audio.play()
    key.classList.add('playing')
}
// 封装移除样式的方法
function removePlay(e) {
    if (e.propertyName !== 'transform') return
    e.target.classList.remove('playing')
}
// Array.from可以把伪数组转换成数组，这样就可以用数组的方法了
const keys = Array.from(document.querySelectorAll('.key'))
keys.forEach(key => key.addEventListener('transitionend', removePlay))